// JavaScript Document
var formReturn=$('#formReturn');
var error=false;
var check_username=function(e){
	      var obj=$('#username');
          if(obj.val()){
			obj.css({'disabled':true});
			$.ajax({
				url: '/ajax/check.php?action=username',
				data: 'hash2=$sys_hash2&username='+encodeURI($(obj).val()),
				type: "POST",
				cache: false,
				dataType:"text",
				success: function(data){
					obj.css({'disabled':false});
					if(data=='1'){
						$('#zh').css("color","#468847");
						$('#username').css({border:"1px solid #91ED6D",color:"#468847"});
						$('#username_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
					} else if (data=='2') {
						error=true;
						$('#zh').css("color","#EE5F5B");
						$('#username').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
						$('#username_tip').text('由英文字母、数字、中文，长度在3-14字符之内').css({color:"#EE5F5B",top:"35px",background:"none"});
					} else if (data=='3') {
					    error=true;
						$('#zh').css("color","#EE5F5B");
						$('#username').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
						$('#username_tip').text('该用户名已存在').css({color:"#EE5F5B",top:"43px",background:"none"});
					} else{
					    error=true;
						$('#zh').css("color","#EE5F5B");
						$('#username').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
						$('#username_tip').text('请刷新后在试').css({color:"#EE5F5B",background:"none",top:"43px"});
					}
				}
			});
		}
		else
		{
		  error=true;
		  $('#zh').css("color","#EE5F5B");
		  $('#username').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
		  $('#username_tip').text('用户名不能为空').css({color:"#EE5F5B",background:"none",top:"43px"});
		}
};
var check_password=function(){
       var objvalue=$('#password').val();
	   var strRegex = /^[0-9a-zA-Z]{6,20}$/g;
       var re=new RegExp(strRegex);
	   if(objvalue){
	   if(re.test(objvalue)){
			$('#pd').css("color","#468847");
			$('#password').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#password_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
	   }else if (objvalue.length<6){
	        error=true;
			$('#pd').css("color","#EE5F5B");
			$('#password').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password_tip').text('密码最少6位').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }else {
		   error=true;
		   $('#pd').css("color","#EE5F5B");
			$('#password').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password_tip').text('密码格式错误').css({color:"#EE5F5B",background:"none",top:"43px"});
		   }
	   }
	   else
	   {
	        error=true;
			$('#pd').css("color","#EE5F5B");
			$('#password').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password_tip').text('请填写密码').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
	   
};
var check_passwordt=function(){
       var objvalue=$('#passwordt').val();
	   var objvalue2=$('#password').val();
	   if(objvalue.length && (objvalue==objvalue2)){
		   if(objvalue.length>=6){
				$('#pdt').css("color","#468847");
				$('#passwordt').css({border:"1px solid #91ED6D",color:"#468847"});
				$('#passwordt_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
		   }else if (objvalue.length<6){
		        error=true;
				$('#pdt').css("color","#EE5F5B");
				$('#passwordt').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
				$('#passwordt_tip').text('密码最少6位').css({color:"#EE5F5B",background:"none",top:"43px"});
		   }
	   }
	   else
	   {
	        error=true;
			$('#pdt').css("color","#EE5F5B");
			$('#passwordt').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#passwordt_tip').text('二次密码输入不一致').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
	   
};
var check_password2=function(){
       var objvalue=$('#password2').val();
	   var strRegex = /^[0-9a-zA-Z]{6,20}$/g;
       var re=new RegExp(strRegex);
	   if(objvalue){
	   if(re.test(objvalue)){
			$('#pd2').css("color","#468847");
			$('#password2').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#password2_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
	   }else if (objvalue.length<5){
	        error=true;
			$('#pd2').css("color","#EE5F5B");
			$('#password2').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password2_tip').text('安全码最少为6位').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }else {
		   error=true;
		    $('#pd2').css("color","#EE5F5B");
			$('#password2').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password2_tip').text('安全码格式错误').css({color:"#EE5F5B",background:"none",top:"43px"});
		   }
	   }
	   else
	   {
	        error=true;
			$('#pd2').css("color","#EE5F5B");
			$('#password2').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#password2_tip').text('请填写安全码').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
	   
};
var check_passwordt2=function(){
       var objvalue=$('#passwordt2').val();
	   var objvalue2=$('#password2').val();
	   if(objvalue.length && (objvalue==objvalue2)){
		   if(objvalue.length>=6){
				$('#pdt2').css("color","#468847");
				$('#passwordt2').css({border:"1px solid #91ED6D",color:"#468847"});
				$('#passwordt2_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
		   }else if (objvalue.length<6){
		        error=true;
				$('#pdt2').css("color","#EE5F5B");
				$('#passwordt2').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
				$('#passwordt2_tip').text('安全码最少为6位').css({color:"#EE5F5B",background:"none",top:"43px"});
		   }
	   }
	   else
	   {
	        error=true;
			$('#pdt2').css("color","#EE5F5B");
			$('#passwordt2').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#passwordt2_tip').text('二次安全码输入不一致').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
	   
};
var check_qq=function(){
       var objvalue=$('#qq').val();
	   var strRegex = /^\d+$/;
       var re=new RegExp(strRegex);  
	   if(re.test(objvalue)){
		    $('#qqt').css("color","#468847");
			$('#qq').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#qq_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
			$("#email").val($("#qq").val()+"@qq.com");
			$('#em').css("color","#468847");
			$('#email').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#em_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
	   }
	   else
	   {
	            error=true;
				$('#qqt').css("color","#EE5F5B");
				$('#qq').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
				$('#qq_tip').text('格式错误').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
	   
};
var check_mobil=function(){
       var objvalue=$('#mobilephone').val();
	   var strRegex = /^1(?:(?:3[0-9])|(?:5[0-35-9])|(?:4[0-35-9])|(?:8[0-35-9]))\d{8}$/;
       var re=new RegExp(strRegex);  
	   if(re.test(objvalue)){
		    $('#telt').css("color","#468847");
			$('#mobilephone').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#tel_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
	   }
	   else
	   {
	        error=true;
			$('#telt').css("color","#EE5F5B");
			$('#mobilephone').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#tel_tip').text('格式错误').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
};
var check_email=function(){
       var objvalue=$('#email').val();
	   var strRegex = /^[a-z0-9][a-z0-9_]+@[a-z0-9]+(\.[a-z0-9]+){1,3}$/i;
       var re=new RegExp(strRegex);  
	   if(re.test(objvalue)){
		    $('#em').css("color","#468847");
			$('#email').css({border:"1px solid #91ED6D",color:"#468847"});
			$('#em_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
	   }
	   else
	   {
	        error=true;
			$('#em').css("color","#EE5F5B");
			$('#email').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
			$('#em_tip').text('格式错误').css({color:"#EE5F5B",background:"none",top:"43px"});
	   }
};
var check_parent=function(){
	      var obj=$('#parent');
          if(obj.val()){
			obj.attr({'disabled':true});
			$.ajax({
				url: '/ajax/check.php?action=parent',
				data: 'hash2=$sys_hash2&parent='+encodeURI($(obj).val()),
				type: "POST",
				cache: false,
				dataType:"text",
				success: function(data){
					obj.attr({'disabled':false});
					if(data=='1'){
						$('#tj').css("color","#468847");
						$('#parent').css({border:"1px solid #91ED6D",color:"#468847"});
						$('#tj_tip').text('').css({top:"43px",background:"url(/images/user/reg_03.jpg) no-repeat"});
					} else{
						$('#tj').css("color","#EE5F5B");
						$('#parent').css({border:"1px solid #EE5F5B",color:"#EE5F5B"});
						$('#tj_tip').text('推荐人不存在').css({color:"#EE5F5B",background:"none",top:"43px"});
					}
				}
			});
		}else
		{
			$('#tj').css("color","#666666");
			$('#parent').css({border:"1px solid #DDDDDD"});
			$('#tj_tip').text('');
		}
};
var checkform=function(e){
	    check_username();
		check_password();
		check_passwordt();
		check_password2();
		check_passwordt2();
		check_qq();
		check_mobil();
		check_email();
		if(!error){
			return true;
		} else return false;
  };
$(document).ready(function(){
	$('#myregForm').submit(function(){
	return checkform();
    });
	$('#agreement').click(function(){
	comm_720fram(720, 335, "安全问题", "", "<div style=\"margin:10px 20px;\"><span style=\"color:#006600;\">一、</span>用户注册时应填写各项真实资料（尤其是QQ，Email，手机）如资料不真实出现任何问题官方都不予保护及处理。一旦发生任务纠纷，任务一方联系对方如发现其QQ，EMAIL或者手机不真实，经官方核实将立即封停此帐号！各会员请及时修改自己的详细资料。<br /><span style=\"color:#006600;\">二、</span>所有会员注册请牢记自己的操作密码。勿将操作密码告诉他人，如出现帐号被人盗取存款被他人提现官方不负任何责任。<br /><span style=\"color:#006600;\">三、</span>所有平台会员在平台应当互敬互爱，严禁言语辱骂，恐吓对方，如有投诉经查证警告处理，严重者封号<br /><span style=\"color:#006600;\">四、</span>会员不能在平台论坛发布与平台有冲突重复的帖子，处罚规则：删除帖子，封号处理。<br /><span style=\"color:#006600;\">五、</span>严禁使用任何手段欺骗，恐吓等办法骗取其他会员资金或存款，如淘宝恶性退款包括但不仅限于一经发现立即封号！情节严重将移交公安部门处理并予以平台公示！<br /><span style=\"color:#006600;\">六、</span>严禁通过旺旺联系对方并带有平台、信用、信誉等敏感字眼。<br /><span style=\"color:#006600;\">七、</span>任何会员在做任务时严禁拖对方任务。（如遇特殊情况可QQ或电话联系对方）<br /><span style=\"color:#006600;\">八、</span>如有任务投诉官方客服都会给您留言，如在三天内不上线与客服联系处理。将被视为默认放弃。客服将按对方所提供证据进行裁定。（请各位会员在下线时检查自己所有任务是否都已完成）<br /><span style=\"color:#006600;\">九、</span>官方对任何已经完成的任务申诉不予任何受理。请各位会员认真对待自己的每一个任务，不要拿自己的金钱当作游戏。也不要图一时之快浪费更多的时间精力。<br /><span style=\"color:#006600;\">十、</span>不允许发一个任务却让接手方拍淘宝多个连接。<br /><span style=\"color:#006600;\">十一、</span>严禁乱写评语，以及广告评语，一经发现立即封号，处罚30个实物麦点解封。<br /><span style=\"color:#006600;\">十二、</span>禁止任何理由给对方差评，一经发现终身封停其帐号。<br /><span style=\"color:#006600;\">十三、</span>除官方明确规定可罚款解封的情况，其他封停帐号一律不退还存款及麦点。<br /><span style=\"color:#006600;\">十四、</span>关于提现：避免恶意套现，提现只接受完成任务，兑换麦点，推广奖励的存款，通过淘宝店铺，网银充值的存款将拒绝提现申请。<br><span style=\"background-color:#ffffff;\"><span style=\"color:#006600;\">十五、</span></span>禁止帮他人发布任务，这样会导致您的朋友无法在大麦户平台发布。除遵守本制度外，其他平台公告制度同等有效，如平台其他制度与本制度重复，以本制度为最终依据。&nbsp;</div><div style='padding:10px;text-align:center;'><input onclick='doCut();' class=btn_dft type='button' tabindex='9' value='关 闭'></div>");
    });	
});